package com.qiangesoft.security.controller;

import com.qiangesoft.security.pojo.ResultVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;

/**
 * 接口测试
 *
 * @author qiangesoft
 * @date 2024-05-14
 */
@RestController
public class TestController {

    @GetMapping("/")
    public ResultVO index() {
        return ResultVO.ok("Hello world !");
    }

    @PreAuthorize("hasRole('admin')")
    @GetMapping("/admin")
    public ResultVO admin() {
        return ResultVO.ok();
    }

    @PreAuthorize("hasAnyRole('admin', 'common')")
    @GetMapping("/common")
    public ResultVO common() {
        return ResultVO.ok();
    }

    @PreAuthorize("hasAuthority('add')")
    @GetMapping("/add")
    public ResultVO add() {
        return ResultVO.ok();
    }

    @PreAuthorize("hasAuthority('delete')")
    @GetMapping("/delete")
    public ResultVO delete() {
        return ResultVO.ok();
    }

    @PreAuthorize("hasAuthority('update')")
    @GetMapping("/update")
    public ResultVO update() {
        return ResultVO.ok();
    }

    @PreAuthorize("hasAuthority('select')")
    @GetMapping("/select")
    public ResultVO select() {
        return ResultVO.ok();
    }

    @PermitAll
    @GetMapping("/permitAll")
    public ResultVO permitAll() {
        return ResultVO.ok();
    }

    @DenyAll
    @GetMapping("/denyAll")
    public ResultVO denyAll() {
        return ResultVO.ok();
    }

}
